﻿package mortal.game.view.common.guide
{
    import flash.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.systemSetting.*;

    public class AutoGuideStepRecorder extends Object
    {
        private var _doneSteps:Dictionary;
        private var _doingSteps:Dictionary;
        private var _curDoneSteps:Dictionary;

        public function AutoGuideStepRecorder()
        {
            this._doneSteps = new Dictionary();
            this._doingSteps = new Dictionary();
            this._curDoneSteps = new Dictionary();
            return;
        }// end function

        public function init() : void
        {
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_1:* = ClientSetting.local.autoGuides;
            if (_loc_1 == null || _loc_1.length == 0)
            {
                return;
            }
            var _loc_2:int = 0;
            while (_loc_2 < _loc_1.length)
            {
                
                _loc_3 = _loc_1[_loc_2];
                _loc_4 = ClassTypesUtil.getHighestBitPlace(_loc_3);
                this._doneSteps[_loc_2] = _loc_4;
                _loc_2++;
            }
            return;
        }// end function

        public function saveStepDone(param1:int, param2:int) : void
        {
            if (ClientSetting.local.autoGuides == null)
            {
                ClientSetting.local.autoGuides = [];
            }
            if (ClientSetting.local.autoGuides[param1] == null)
            {
                ClientSetting.local.autoGuides[param1] = 0;
            }
            var _loc_3:* = ClientSetting.local.autoGuides[param1];
            _loc_3 = ClassTypesUtil.getSetBitValueResult(_loc_3, (param2 - 1), 1);
            ClientSetting.local.autoGuides[param1] = _loc_3;
            this.saveRecord();
            return;
        }// end function

        public function getIsStepFinished(param1:int, param2:int) : Boolean
        {
            var _loc_3:* = ClientSetting.local.autoGuides;
            if (_loc_3 == null || _loc_3.length == 0)
            {
                return false;
            }
            var _loc_4:* = int(_loc_3[param1]);
            return ClassTypesUtil.getBitValue(_loc_4, param2) > 0;
        }// end function

        public function getHighestGuideStep(param1:int) : int
        {
            var _loc_2:int = 0;
            if (ClientSetting.local.autoGuides == null)
            {
                ClientSetting.local.autoGuides = [];
            }
            var _loc_3:* = int(ClientSetting.local.autoGuides[param1]);
            var _loc_4:int = 0;
            while (_loc_4 < 31)
            {
                
                if (ClassTypesUtil.getBitValue(_loc_3, _loc_4) == 1)
                {
                    _loc_2 = _loc_4;
                }
                _loc_4++;
            }
            return _loc_2;
        }// end function

        public function getDoneStep(param1:int) : int
        {
            return int(this._doneSteps[param1]);
        }// end function

        public function addDoneStep(param1:int, param2:int) : void
        {
            this._doneSteps[param1] = param2;
            return;
        }// end function

        public function get doingStes() : Dictionary
        {
            return this._doingSteps;
        }// end function

        public function addDoingStep(param1:int, param2:int) : void
        {
            this._doingSteps[param1] = param2;
            return;
        }// end function

        public function delDoingId(param1:int) : void
        {
            this._doingSteps[param1] = 0;
            return;
        }// end function

        public function getDoingStep(param1:int) : int
        {
            return int(this._doingSteps[param1]);
        }// end function

        public function addCurDonStep(param1:int, param2:int) : void
        {
            this._curDoneSteps[param1] = param2;
            return;
        }// end function

        public function getCurDoneStep(param1:int) : int
        {
            return int(this._curDoneSteps[param1]);
        }// end function

        private function saveRecord() : void
        {
            ClientSetting.save(true);
            return;
        }// end function

    }
}
